package web.Order;

import com.google.gson.Gson;
import entity.OrdersBean;
import services.OrdersService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.List;
@WebServlet("/searchOrders")
public class SearchOrders extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json");
        String courts_type_name = req.getParameter("courts_type_name");
        String payment_state = req.getParameter("payment_state");
        String courts_table = req.getParameter("courts_table");
        List<OrdersBean> ordersBeans = new OrdersService().searchOrders(courts_type_name, payment_state, courts_table);
        Gson gson = new Gson();
        String json = gson.toJson(ordersBeans);
        resp.getWriter().println(json);
    }
}
